package com.pacy.pacybaseproject.base;

import androidx.databinding.ViewDataBinding;

import me.goldze.mvvmhabit.base.BaseFragment;
import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.views.StateLayout;

/**
 * @author PACY
 * @date 2021/11/25
 * description:
 */
public abstract class BaseXFragment<V extends ViewDataBinding, VM extends BaseViewModel> extends BaseFragment<V, VM> {
    private StateLayout stateLayout;

    public void setStateLayout(StateLayout stateLayout) {
        this.stateLayout = stateLayout;
    }

    @Override
    public void showLoading() {
        super.showLoading();
        if (stateLayout != null) {
            stateLayout.showLoading();
        }
    }

    @Override
    public void showContent() {
        super.showContent();
        if (stateLayout != null) {
            stateLayout.showContent();
        }
    }

    @Override
    public void showError() {
        super.showContent();
        if (stateLayout != null) {
            stateLayout.showError();
        }
    }

    @Override
    public void showEmpty() {
        super.showEmpty();
        if (stateLayout != null) {
            stateLayout.showEmptyContent();
        }
    }
}
